<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>根据位置返回字符</title>
    <script>
        // 1. 返回指定位置的字符
        var str = 'andy';
        console.log(str.charAt(3));
        //遍历所有字符
        for (var i = 0;i < str.length;i++) {
        console.log(str.charAt(i));
        }
        // 2. 返回指定位置的SAII码 判断用户点击了哪个键盘
        console.log(str.charCodeAt(0));
        // 3. h5新增 ie8+
        console.log(str[0]);
    </script>
</head>
<body>
    
</body>
</html>